package com.example.hello.reflect;

public class LoginTest {
    public static void main(String[] args) throws Exception {
        //模拟后台数据库中存储的用户信息
        UserInfo user_vip = new UserInfo("Guojing", "123456","VIPUser");
        UserInfo user_com = new UserInfo("user_com", "789","COMUser");
        //模拟用户登录输入的数据
        User user_test = new User("Guojing","123456");
        //使用反射获取用户登录输入的数据
        Login loginimple = new LoginImpl();
        System.out.println(loginimple.login(user_test));
        String[] arr = loginimple.login(user_test).split(" ");
        String name = arr[0];
        String psd = arr[1];
        //和后台储存的数据进行比较，判断其是否为VIP用户
        if(name.equals(user_vip.getUsername()) && psd.equals(user_vip.getUserpsd())){
            System.out.println("user_test is "+user_vip.getAuth());
        }
        if(name.equals(user_com.getUsername()) && psd.equals(user_com.getUserpsd())){
            System.out.println("user_test is "+user_com.getAuth());
        }
    }
}
